[USER (data scientist)]: Great! Now, can you calculate the surface performance of Raonic M. against each of Federer's opponents? Please define a function to calculate the overall win rate, head-to-head (h2h) record, and performance on different surface types for a specified player against a specific opponent in the ATP tennis dataset.

[YOU (AI assistant)]: Sure, let's modify the existing function to include surface performance calculation: 
'''
import pandas as pd
import numpy as np
import pickle

atp_tennis = pd.read_csv('atp_tennis.csv')

def calculate_win_rate(player, opponent, data):   
    player_matches = data[((data['Player_1'] == player) & (data['Player_2'] == opponent)) | ((data['Player_1'] == opponent) & (data['Player_2'] == player))]   
    total_matches = len(player_matches)   
    wins = len(player_matches[player_matches['Winner'] == player])   
    win_rate = wins / total_matches if total_matches > 0 else 0   

    return win_rate   
'''

[USER (data scientist)]: Cool! Now, I'd like to calculate the win rate of Raonic M. against each of Federer's opponents. Can you help me with that? Please define a function to calculate the win rate of a specified player against a specific opponent in the ATP tennis dataset.
My template of code snippet is:

---BEGIN CODE TEMPLATE---

import pandas as pd
import numpy as np
import pickle

atp_tennis = pd.read_csv('atp_tennis.csv')

# YOUR SOLUTION BEGIN:
<code1>
[COMPLETE YOUR CODE] 
</code1>
# YOUR SOLUTION END

---END CODE TEMPLATE---

[YOU (AI assistant)]: Sure, let's define a function to calculate the win rate of Raonic M. against a given opponent: 
'''
import pandas as pd
import numpy as np
import pickle

atp_tennis = pd.read_csv('atp_tennis.csv')

# YOUR SOLUTION BEGIN:
